package com.action.message;

import java.util.Map;

import com.db.message.*;
import com.opensymphony.xwork2.ActionContext;

public class DeleteAction {

	private int no[];
	private String sd_rv;

	public int[] getNo() {
		return no;
	}

	public void setNo(int[] no) {
		this.no = no;
	}

	public String getSd_rv() {
		return sd_rv;
	}

	public void setSd_rv(String sd_rv) {
		this.sd_rv = sd_rv;
	}

	public String msgDelete() throws Exception {

		for (int i = 0; i < no.length; i++) {
			System.out.println("delete : " + no[i]);
			if (sd_rv.equals("sd")) {

				MessageDAO.msgSendDelete(no[i]);
			} else {
				MessageDAO.msgRecvDelete(no[i]);
			}
		}
		MessageDAO.msgAllDelete();

		return "success";
	}

	public String msgAllDelete() throws Exception {

		Map session = ActionContext.getContext().getSession();
		String id = (String) session.get("login");
		System.out.println(id);
		if (sd_rv.equals("sd")) {

			MessageDAO.allSendDelete(id);
		} else {
			MessageDAO.allRecvDelete(id);
		}

		MessageDAO.msgAllDelete();

		return "success";
	}

}
